package com.kaifamiao.demo.d0826;

import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Demo04 {

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        // <<倚天屠龙记>>
        list.add("张无忌");
        list.add("周芷若");
        list.add("赵敏");
        list.add("张三");
        list.add("张三丰");

        Stream<String> stream = list.stream();

        // <<天龙八部>>
        Stream<String> stream1 = Stream.of("张三", "萧峰", "段誉", "王语嫣", "虚竹");

        Stream<String> concat = Stream.concat(stream, stream1);

        Map<String, Integer> list1 = concat
                .distinct() // 去掉重复
                .filter(s -> !s.equals("张三"))
                        .collect(Collectors.toMap(s -> s, s -> s.length()));
//                        .collect(Collectors.toUnmodifiableSet());
//                .collect(Collectors.toList());

        System.out.println(list1);
//                .forEach(s -> System.out.println(s));
    }
}
